package nc.ui.test.borrow.ace.handler;

import nc.ui.pub.bill.BillCardPanel;
import nc.ui.pubapp.uif2app.event.IAppEventHandler;
import nc.ui.pubapp.uif2app.event.card.CardBodyAfterEditEvent;
import nc.vo.pub.lang.UFDouble;

public class CardBodyAfterEditHandler implements IAppEventHandler<CardBodyAfterEditEvent>{

	@Override
	public void handleAppEvent(CardBodyAfterEditEvent e) {
		
		BillCardPanel card = e.getBillCardPanel();
		
		if(e.getKey().equals("nprice") || e.getKey().equals("pk_bookdoc")){
//			int rowCount = card.getBillTable().getRowCount();
//			
//			UFDouble nprice = null;
			UFDouble ntotalprice = UFDouble.ZERO_DBL;
			
//			for(int row = 0; row < rowCount; row ++){
//				nprice = (UFDouble) card.getBillModel().getValueObjectAt(row, "nprice");
//				
//				if(nprice == null){
//					nprice = UFDouble.ZERO_DBL;
//				}
//				
//				ntotalprice = ntotalprice.add(nprice);
//			}
			
			ntotalprice = (UFDouble) card.getBillModel().getTotalTableModel().getValueAt(0, card.getBillModel().getItemIndex("nprice"));
			
			
			card.setHeadItem("ntotalprice", ntotalprice);
		}
		
	}

}
